package com.atguigu.spzx.cloud.order.controller;


import com.atguigu.spzx.cloud.model.entity.Order;
import com.atguigu.spzx.cloud.order.service.OrderService;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.http.HttpRequest;
import java.util.List;

@RestController
@RequestMapping(value = "/api/order")
public class OrderController {

    @Autowired
    private OrderService orderService ;

    @GetMapping(value = "/findOrderByOrderId/{orderId}")
    public Order findOrderByOrderId(@PathVariable("orderId") Long orderId , HttpServletRequest request) {
//        String truth = request.getHeader("Truth");
        return orderService.findOrderByOrderId(orderId);
    }

    @GetMapping(value = "/findOrderListByUserId/{userId}")
    public List<Order> findOrderListByUserId(@PathVariable("userId") Long userId) {
        List<Order>  orderList = orderService.findOrderListByUserId(userId);
        return orderList;
    }




}